package com.xiashitech.agent.instrumentation.httprequest.inst;

import com.google.auto.service.AutoService;
import com.xiashitech.agent.instrumentation.httprequest.inst.XSRequestInstrumentation;
import com.xiashitech.agent.instrumentation.httprequest.inst.XSHttpRequestInstrumentation;
import com.xiashitech.agent.rule.usermatch.Register;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static java.util.Arrays.asList;
@AutoService(InstrumentationModule.class)
public class XSHttpRequestInstrumentationModule extends InstrumentationModule {
    public XSHttpRequestInstrumentationModule() {
        super("http-servlet-filter-request");
    }

    @Override
    public List<TypeInstrumentation> typeInstrumentations() {
        return asList(new XSHttpRequestInstrumentation(),new XSRequestInstrumentation());
    }

    @Override
    public List<String> getAdditionalHelperClassNames() {
        List<String> helperClassNames = new ArrayList();
        helperClassNames.addAll(Arrays.asList("com.xiashitech.agent.instrumentation.helper.calldepth.XSHttpRequestCallDepth",
                "com.xiashitech.agent.instrumentation.helper.calldepth.XSRequestCallDepth",
                "com.xiashitech.agent.instrumentation.httprequest.servlet.XSHttpRequestSingletons",
                "com.xiashitech.agent.instrumentation.httprequest.filter.XSRequestSingletons",
                "com.xiashitech.agent.instrumentation.httprequest.XSHttpRequestAttributesExtractor",
                "com.xiashitech.agent.utils.SessionUtil",
                "com.xiashitech.agent.instrumentation.httprequest.XSHttpServletRequestWrapper",
                "com.xiashitech.agent.instrumentation.httprequest.utils.RequestInfoUtil",
                "com.xiashitech.agent.instrumentation.httprequest.XSServletInputStream",
                "com.xiashitech.agent.instrumentation.httprequest.XSHttpServletResponseWrapper",
                "com.xiashitech.agent.instrumentation.httprequest.XSServletOutputStream",
                "com.xiashitech.agent.instrumentation.httprequest.utils.SpecialUtil"));
        helperClassNames.addAll(Register.registUserMatch());
        return helperClassNames;
    }
}
